package com.xiehua.task.client.example;

import com.xiehua.task.client.job.JobExecuter;
import com.xiehua.task.job.pool.Job;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class B2cJobExecuter implements JobExecuter{

    private static Logger log = LoggerFactory.getLogger(B2cJobExecuter.class);

    /**
     * 执行job
     *
     * @param bizDate
     * @return boolean
     **/
    @Override
    public boolean asynExecute(String bizDate) throws RuntimeException {
        log.info("我是延迟任务-->开始执行任务。。。"+bizDate);
        return true;
    }

    /**
     * 异步提交job
     *
     * @param job
     * @return 本次任务注册的请求id
     **/
    @Override
    public String asynSubmitJob(Job job) throws RuntimeException {
        //TODO reg job to server
        return job.getReqId();
    }

    /**
     * 异步接收job提交的结果
     *
     * @param reqId  任务注册时返回的请求id
     * @param taskId 任务中心分配的任务id
     * @param result 任务注册结果
     **/
    @Override
    public void asynNotifyResult(String reqId, String taskId, Boolean result) throws RuntimeException {
        //任务注册完成
        log.info("任务注册完成:reqId->{},taskId->{},result->{}",reqId,taskId,result);
    }
}
